package api

import (
	"github.com/gin-gonic/gin"
	middleware2 "poem-server/middleware"
)

type Router struct {
}

func NewRouter() Router {
	return Router{}
}

func (r Router) Load() {
	router := gin.Default()

	// TODO 添加中间件
	router.Use(middleware2.CorsHandler())     // 跨域中间件
	router.Use(middleware2.RecoveryHandler()) // 恢复中间件
	router.Use(middleware2.LogHandler())      // 日志中间件

	// TODO 添加路由
	AddUserRouter(router)
	AddPoemRouter(router)
	addUploadRouter(router)

	// TODO 启动！ 启动！ 还有这个全部 启动！
	router.Run(":8080")
}
